class Solution:
    def isPowerOfTwo(self, n: int) -> bool:
        # 法一：循环判断
        # if n <= 0:
        #     return False
        # while n % 2 == 0:
        #     n //= 2
        # return n == 1
        # 法二：位运算判断
        return n > 0 and (n&(n-1)) == 0
if __name__ == '__main__':
    s = Solution()
    print(s.isPowerOfTwo(16))